package com.example.liverock.androidalltest;

import android.app.Activity;
import android.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

public class AlertDialogActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alert_dialog);

        Button button = (Button)findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(AlertDialogActivity.this);
                builder.setTitle("用户登录：");
                // 设置 longin.xml  界面
                LayoutInflater inflater = getLayoutInflater();
                View view = inflater.inflate(R.layout.login, null);
                builder.setView(view);
                //添加确定按钮
                builder.setPositiveButton("登录", null);
                //添加取消按钮
                builder.setNegativeButton("退出", null);
                // 创建对话框并显示
                builder.create().show();
            }
        });
    }
}
